package com.lineage.data.npc.shop;

import com.lineage.data.executor.NpcExecutor;
import com.lineage.server.model.Instance.L1NpcInstance;
import com.lineage.server.model.Instance.L1PcInstance;
import com.lineage.server.serverpackets.S_NPCTalkReturn;
import com.lineage.server.serverpackets.S_ShopBuyListCn;
import com.lineage.server.serverpackets.ServerBasePacket;

public class Npc_CnitemRecycling extends NpcExecutor {
  private int _itemid = 44070;
  
  private String _htmlid = null;
  
  public static NpcExecutor get() {
    return new Npc_CnitemRecycling();
  }
  
  public int type() {
    return 3;
  }
  
  public void talk(L1PcInstance pc, L1NpcInstance npc) {
    if (this._htmlid != null) {
      pc.set_temp_adena(this._itemid);
      pc.sendPackets((ServerBasePacket)new S_NPCTalkReturn(npc.getId(), this._htmlid));
    } else {
      pc.set_temp_adena(this._itemid);
      pc.sendPackets((ServerBasePacket)new S_NPCTalkReturn(npc.getId(), "tzmerchant"));
    } 
  }
  
  public void action(L1PcInstance pc, L1NpcInstance npc, String cmd, long amount) {
    if (cmd.equalsIgnoreCase("sell"))
      pc.sendPackets((ServerBasePacket)new S_ShopBuyListCn(pc, npc)); 
  }
  
  public void set_set(String[] set) {
    try {
      this._itemid = Integer.parseInt(set[1]);
    } catch (Exception exception) {}
    try {
      this._htmlid = set[2];
    } catch (Exception exception) {}
  }
}
